package cn.com.fattiger.framework.cms.admin.common.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.stereotype.Service;

import cn.com.fattiger.framework.cms.admin.common.dao.QuestionnaireRepository;
import cn.com.fattiger.framework.cms.admin.common.model.Questionnaire;
import cn.com.fattiger.framework.cms.admin.common.service.QuestionnaireService;

@Service
public class QuestionnaireServiceImpl implements QuestionnaireService {

	@Autowired
	private QuestionnaireRepository questionnaireRepository;
	
	@Override
	public void save(Questionnaire entity) {
		questionnaireRepository.save(entity);
	}

	@Override
	public void delete(Long id) {
		questionnaireRepository.delete(id);
	}

	@Override
	public Page<Questionnaire> list(Integer page, Integer pageSize) {
		Pageable pageable = new PageRequest(page, pageSize, Direction.DESC, "createtime");
		return questionnaireRepository.findAll(pageable);
	}

	@Override
	public Questionnaire get(Long id) {
		return questionnaireRepository.findOne(id);
	}

	@Override
	public Page<Questionnaire> list(Integer page, Integer pageSize,
			Map<String, String> condition) {
		return null;
	}

	@Override
	public List<Questionnaire> list(Map<String, String> condition) {
		// TODO Auto-generated method stub
		return null;
	}

}
